#include "CEnemy.h"
#include "..\Messaging\DHD_Messages.h"
#include "..\Messaging\DHD_MessageSystem.h"
#include "../Wrappers/CSGD_Direct3D.h"
#include "..\Wrappers\CSGD_TextureManager.h"
#include "..\CCamera.h"
#include "..\Game States\CGamePlayState.h"
#include "..\Messaging\DHD_Messages.h"
#include "..\Messaging\DHD_MessageSystem.h"
#include <ctime>
CEnemy::CEnemy()
{
	m_nType = OBJ_ENEMY;
}
CEnemy::~CEnemy()
{
}
void CEnemy::GenerateCombo()
{
	for( int i = 0; i < m_nComboSize; i++ )
	m_HP[i] = rand()%4 + 1;
}

bool CEnemy::CheckCollision( IBaseInterface* pBase )
{
	return false;
}
RECT CEnemy::GetCollisionRect()
{
	RECT fake = {0,0,0,0};
	return fake;
}

void CEnemy::HandleEvent(CEvent* pEvent)
{	

}

void CEnemy::Update(float _fDT)
{
	if( CGamePlayState::GetInstance()->GetButtonStack().size() == this->getComboSize())
	{
		for( int i = 0; i < 4; i ++ )
		{
		if((CGamePlayState::GetInstance()->GetSingleButtonStack(i)) != m_HP[i])
			break;
		else
			continue;
		}
		if( (CGamePlayState::GetInstance()->GetSingleButtonStack(getComboSize()-1)) == (m_HP[getComboSize()-1]) )
		{
			DHD_MessageSystem::GetInstance()->SendMsg( new CDestroyEnemyMessage(this) );
		}
	}
}

void CEnemy::Render()
{
	char combo[100];

	sprintf(combo, "<%i %i %i %i>", m_HP[0],m_HP[1],m_HP[2],m_HP[3]);

	CSGD_Direct3D::GetInstance()->DrawTextA(combo,GetPosX()+CCamera::GetInstance()->GetPosX(),GetPosY() - 20,0,0,0);
	CSGD_TextureManager::GetInstance()->Draw(GetImageID(),GetPosX()+CCamera::GetInstance()->GetPosX() , GetPosY());
}





